﻿using Admin.Core.Common.BaseModel;
using FreeSql;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Admin.Core.Repository.Base
{
    /// <summary>
    /// 只带工厂的实体仓库接口
    /// </summary>
    public interface IRepositoryTenantBase<TEntity, TKey> : IBaseRepository<TEntity, TKey> where TEntity : class, IEntityTenant
    {
        public IBaseRepository<TEntity> baseRepository { get; }

        /// <summary>
        /// 获得Dto
        /// </summary>
        /// <typeparam name="TDto"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<TDto> GetAsync<TDto>(TKey id);

        /// <summary>
        /// 根据条件获取实体
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        Task<TEntity> GetAsync(Expression<Func<TEntity, bool>> exp);

        /// <summary>
        /// 根据条件获取Dto
        /// </summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        Task<TDto> GetAsync<TDto>(Expression<Func<TEntity, bool>> exp);

        /// <summary>
        /// 软删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> SoftDeleteAsync(TKey id);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> SoftDeleteAsync(TKey[] id);
    }


    /// <summary>
    /// 带工厂的实体仓库接口
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IRepositoryTenantBase<TEntity> : IRepositoryTenantBase<TEntity, long> where TEntity : class, IEntityTenant
    {
    }
}
